﻿<%@ Control Language="VB" AutoEventWireup="false" CodeFile="Edit.ascx.vb" Inherits="FrontEnd_Control_Product_Edit" %>
<%@ Register TagPrefix="aspNewControls" Namespace="NewControls" %>
<%@ Register TagPrefix="CE" Namespace="CuteEditor" Assembly="CuteEditor" %>
 <script type="text/javascript">
     function ajaxJquery() {

         $(function () {
             $(".TextBox:first").focus();
             $(".ItemDisabled").attr("disabled", "true");


             //Upload Image
             $('#file_upload').uploadify({
                 'uploader': '<%=ResolveUrl("~/uploadify/uploadify.swf")%>',
                 'script': '<%=ResolveUrl("~/uploadify/UploadProduct.ashx?folder=ImageStorage")%>',
                 'cancelImg': '<%=ResolveUrl("~/uploadify/cancel.png")%>',
                 'folder': '<%=ResolveUrl("~/Uploads")%>',
                 'auto': false,
                 'multi': false,
                 'fileExt': '*.jpg;*.gif;*.png;*.jpeg;*.bmp',
                 'fileDesc': 'Web Image Files (.JPG, .GIF, .PNG , .JPEG , .BMP)',
                 'fileDataName': 'myfile',
                 'sizeLimit': '<%= ConfigurationManager.AppSettings("maxupload") %>',
                 'onComplete': function (event, ID, fileObj, response, data) {
                     $('#<%=hidImagePath.ClientID %>').val('<%= ConfigurationManager.AppSettings("ImageDomain") %>' + response);
                     $('#<%=imgUpload.ClientID %>').attr("src", '<%= ConfigurationManager.AppSettings("ImageDomain") %>' + response);
                 }
             });

             //Upload Album 
             var str = "";
             $('#fileAlbum').uploadify({
                 'uploader': '<%=ResolveUrl("~/uploadify/uploadify.swf")%>',
                 'script': '<%=ResolveUrl("~/uploadify/UploadAlbum.ashx?folder=ImageStorage")%>',
                 'cancelImg': '<%=ResolveUrl("~/uploadify/cancel.png")%>',
                 'folder': '<%=ResolveUrl("~/Uploads")%>',
                 'auto': false,
                 'multi': true,
                 'fileExt': '*.jpg;*.gif;*.png;*.jpeg;*.bmp',
                 'fileDesc': 'Web Image Files (.JPG, .GIF, .PNG , .JPEG , .BMP)',
                 'fileDataName': 'fileAlbum',
                 'sizeLimit': 10240000,
                 'onComplete': function (event, ID, fileObj, response, data) {
                     str += '<%= ConfigurationManager.AppSettings("ImageDomain") %>' + response.toString();
                 },
                 'onAllComplete': function (event, data) {
                     str += "0";
                     var myAlbum = new Array();
                     myAlbum = str.split(",");
                     str = "";
                     for (var i = 0; i < myAlbum.length - 1; i++) {
                         var index = 0;
                         index = Math.floor(Math.random() * 100);
                         $(".GridBorder").append("<tr id='" + index + "' ><td Width='10%' class='text_list_links' align='center' > <a  class='delbutton' style='cursor:pointer;' onclick='RemoveRow(" + index + ");' > Xóa </a> </td> <td Width='20%' class='text_list_links' align='left' > <img alt=''   src='" + myAlbum[i] + "' Style='width: 100px; height: 68px; top: 0px; left: 0px;' class='ag-Jd-Pd' /> </td><td Width='20%' class='text_list_links' align='left' ><textarea id='TextArea1' cols='15' rows='4'></textarea></td></tr>");
                     }
                 }
             });
         });
     }
     function RemoveRow(i) {
         $(".GridBorder #" + i).remove();

     }
     function showImage(i, title, desc) {
         $(".GridBorder").append("<tr id='" + i + "' ><td Width='10%' class='text_list_links' align='center' > <a  class='delbutton' style='cursor:pointer;' onclick='RemoveRow(" + i + ");' > Xóa </a> </td> <td Width='20%' class='text_list_links' align='left' > <img alt=''   src='" + title + "' Style='width: 100px; height: 68px; top: 0px; left: 0px;' class='ag-Jd-Pd' /> </td><td Width='20%' class='text_list_links' align='left' ><textarea id='TextArea1' cols='15' rows='4'>" + desc + "</textarea></td></tr>");
     }

     function getAllImages() {
         var strImage = "";
         var strComment = "";
         $(".GridBorder tr td img").each(function (e) {
             strImage += $(this).attr("src") + ","
         });
         $(".GridBorder tr td textarea").each(function (e) {
             strComment += $(this).val() + ";"
         });
         $("#<%=hidStrImage.ClientID()%>").val(strImage + '0');
         $("#<%=hidStrCommnet.ClientID()%>").val(strComment + '0');
     }
</script>
<asp:UpdatePanel ID="uplProduct" runat="server">
    <ContentTemplate>
        <div class="BoxField" style="background-color:#ffffff;font-family: Arial,tahoma;
    font-size: 10pt;">
             <div class="HeadTitle">
                <h3>
                    <asp:Label ID="Label2" runat="server" Text=" CHỈNH SỬA SẢN PHẨM" /></h3>
            </div>
            <div class="DivRequired">
                <span class="fieldRequired">&nbsp;</span>Trường yêu cầu nhập dữ liệu
            </div>
            <div class="Error">
                <asp:ValidationSummary ID="ValidationSummary1" runat="server" ForeColor="#FF3300" />
            </div>
            <div class="DivRow">
                <div class="DivLabel">
                    <asp:Label ID="lblTitle" CssClass="TextLabel" runat="server" Text="Tên sản phẩm:" /><span class="fieldRequired">&nbsp;</span>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtTitle"
                        Display="None" ErrorMessage="Vui lòng  nhập tên sản phẩm."></asp:RequiredFieldValidator>
                </div>
                <div class="DivTextBox">
                    <asp:TextBox ID="txtTitle" Width="510px" CssClass="TextBox" runat="server" Text="" />
                </div>
            </div>
            <div class="DivRow">
                <div class="DivLabel">
                    <asp:Label ID="lblDescription" CssClass="TextLabel" runat="server" Text="Mô tả:" />
                </div>
                <div class="DivTextBox">
                    
                </div>
            </div>
            <div class="DivRow">
                <div class="DivTextBox">
                    <CE:Editor ID="txtDescription" runat="server" Width="100%" Height="500" EditorWysiwygModeCss="~/example.css">
                        <FrameStyle BackColor="White" BorderColor="#DDDDDD" BorderStyle="Solid" BorderWidth="1px"
                            CssClass="CuteEditorFrame" Height="100%" Width="100%" />
                    </CE:Editor>
                </div>
            </div>
                  <div class="DivRow" style="display:none" >
                <div class="DivLabel">
                    <asp:Label ID="lblStoreid" CssClass="TextLabel" runat="server" Text="Gian hàng:" />
                </div>
                <div class="DivTextBox">
                    <asp:DropDownList ID="ddlStore" runat="server" CssClass="TextBox"  
                        Width="253px" AutoPostBack="True">
                    </asp:DropDownList>
                </div>
            </div>
             <div class="DivRow">
                <div class="DivLabel">
                    <asp:Label ID="Label6" CssClass="TextLabel" runat="server" Text="Ngành hàng:" /><span
                        class="fieldRequired">&nbsp;</span>
                    
                </div>
                <div class="DivTextBox">
                    <asp:DropDownList ID="ddlNganhHang" runat="server"  CssClass="TextBox"
                         Width="253px">
                    </asp:DropDownList>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="ddlNganhHang"
                        Display="None" InitialValue="0" ErrorMessage="Vui lòng  chọn loại loại ngành hàng."></asp:RequiredFieldValidator>
                </div>
            <div class="DivRow" style="display:none">
                <div class="DivLabel">
                    <asp:Label ID="lblStoretypeid" CssClass="TextLabel" runat="server" Text="Loại sản phẩm:" />
                </div>
                <div class="DivTextBox">
                 <aspNewControls:NewDropDownList ID="ddlType" runat="server" CssClass="TextBox"
                     Width="203px">
                </aspNewControls:NewDropDownList>   
                </div>
            </div>
            <div class="DivRow">
                <div class="DivLabel">
                    <asp:Label ID="Label1" CssClass="TextLabel" runat="server" Text="Ảnh đại diện:" />
                    <span class="fieldRequired">&nbsp;</span>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server" 
                        ControlToValidate="hidImagePath" Display="None" 
                        ErrorMessage="Vui lòng  chọn ảnh đại diện."></asp:RequiredFieldValidator>
                </div>
                <div class="DivTextBox">
                    <input id="file_upload" name="file_upload" type="file" /><a id="upload" href="javascript:$('#file_upload').uploadifyUpload();">Upload
                        Files</a>
                </div>
            </div>
            <div class="DivRow">
                <div class="DivLabel">
                    &nbsp;</div>
                <div style="height: 100px;" class="DivTextBox">
                    <asp:Image ID="imgUpload" runat="server" BorderWidth="0px" Height="100px" Width="100px"
                        ImageUrl="~/Images/NoPhotoAvailable.jpg" />
                </div>
            </div>
            <div class="DivRow">
                <div class="DivLabel">
                    <asp:Label ID="Label3" CssClass="TextLabel" runat="server" Text="Các ảnh khác:" />
                    <span class="fieldRequired">
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator7" runat="server" 
                        ControlToValidate="hidStrImage" Display="None" 
                        ErrorMessage="Vui lòng chọn ảnh Album."></asp:RequiredFieldValidator>
                    </span>
                </div>
                <div class="DivTextBox">
                    <input id="fileAlbum" name="file_upload" type="file" />
                    <a id="fileAlbum" href="javascript:$('#fileAlbum').uploadifyUpload();">Upload Files</a>
                </div>
            </div>
            <div class="DivRow" >
              <div class="DivLabel">
                    &nbsp;</div>
            <div style="width: 100%;" class="DivTextBox">
                <table cellpadding="0" width="50%" cellspacing="0" border="1" class="GridBorder">
                    <tr>
                        <td width='10%' class='text_list_links' align='center'>
                        </td>
                        <td width='20%' class='text_list_links' align='left'>
                            Ảnh
                        </td>
                        <td width='20%' class='text_list_links' align='left'>
                            Mô tả
                        </td>
                    </tr>
                </table>
            </div>
            </div>
            
            <div class="DivRow">
                <div class="DivLabel">
                    <asp:Label ID="lblOriginalprice" CssClass="TextLabel" runat="server" Text="Giá bán:" /><span class="fieldRequired">&nbsp;</span>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="txtOriginalprice"
                        Display="None" ErrorMessage="Vui lòng  nhập giá bán sản phẩm."></asp:RequiredFieldValidator>
                    <asp:RangeValidator ID="RangeValidator1" runat="server" 
                        ControlToValidate="txtOriginalprice" Display="None" 
                        ErrorMessage="Giá bán không đúng định dạng." MaximumValue="999999999" 
                        MinimumValue="0" Type="Double"></asp:RangeValidator>
                </div>
                <div class="DivTextBox">
                    <asp:TextBox ID="txtOriginalprice" CssClass="TextBox" runat="server" Text="" />  (ngàn đồng)
                </div>
            </div>
            <div class="DivRow">
                <div class="DivLabel">
                    <asp:Label ID="lblSellprice" CssClass="TextLabel" runat="server" Text="Giá khuyến mại:" />
                    
                    <asp:RangeValidator ID="RangeValidator2" runat="server" 
                        ControlToValidate="txtSellprice" Display="None" 
                        ErrorMessage="Giá khuyến mại không đúng định dạng." MaximumValue="999999999" 
                        MinimumValue="0" Type="Double"></asp:RangeValidator>
                </div>
                <div class="DivTextBox">
                    <asp:TextBox ID="txtSellprice" CssClass="TextBox" runat="server" Text="" />  (ngàn đồng)
                </div>
            </div>
      
            <div class="DivRow">
                <div class="DivLabel">
                    <asp:Label ID="lblIsselloff" CssClass="TextLabel" runat="server" Text="Khuyến mại:" />
                </div>
                <div class="DivTextBox">
                    <asp:CheckBox ID="chkIsselloff" CssClass="TextBox" runat="server" />
                </div>
            </div>
            <div class="DivRow">
                <div class="DivLabel">
                    <asp:Label ID="lblIshot" CssClass="TextLabel" runat="server" Text="Sản phẩm hot:" />
                </div>
                <div class="DivTextBox">
                    <asp:CheckBox ID="chkIshot" CssClass="TextBox" runat="server" />
                </div>
            </div>
            <div class="DivRow">
                <div class="DivLabel">
                    <asp:Label ID="Label10" CssClass="TextLabel" runat="server" Text="Tình trạng:" /><span
                        class="fieldRequired">&nbsp;</span>
                  
                </div>
                <div class="DivTextBox">
                     <asp:DropDownList ID="ddlStatus" runat="server" CssClass="TextBox" 
                        Width="253px">
                        <asp:ListItem Text="Còn hàng"  Value="0" ></asp:ListItem>
                         <asp:ListItem Text="Hết hàng"  Value="1" ></asp:ListItem>
                          <asp:ListItem Text="Ngừng bán"  Value="2" ></asp:ListItem>
                    </asp:DropDownList>
                </div>
            </div>  
             <div class="DivRow">
                <div class="DivLabel">
                    <asp:Label ID="Label13" CssClass="TextLabel" runat="server" Text="Tổng số:" />
             
                    <asp:RangeValidator ID="RangeValidator3" runat="server" ControlToValidate="txtTongSo"
                        Display="None" ErrorMessage="Tổng số không đúng định dạng." MaximumValue="999999999"
                        MinimumValue="0" Type="Double"></asp:RangeValidator>
                </div>
                <div class="DivTextBox">
                    <asp:TextBox ID="txtTongSo" CssClass="TextBox"  runat="server" Text="" />  (sản phẩm)
                </div>
            </div>
    <div class="DivRow" style="display:none">
                <div class="DivLabel"> </div>
                <div class="DivTextBox"><asp:CheckBox ID="chkThayDoiThongTin" Text="Thay đổi thông tin" runat="server" />  </div>
          
             <div class="DivRow">
		<div  class="DivLabel">
			<asp:Label ID="lblDiachi" CssClass="TextLabel" runat="server" Text="Địa chỉ:" />
		</div>
		<div  class="DivTextBox" >
			<asp:TextBox ID="txtDiachi" CssClass="TextBox" runat="server" Text="" />
		</div>
		</div>
		<div class="DivRow">
		<div  class="DivLabel">
			<asp:Label ID="lblPhone" CssClass="TextLabel" runat="server" Text="Điện thoại:" />
		</div>
		<div  class="DivTextBox" >
			<asp:TextBox ID="txtPhone" CssClass="TextBox" runat="server" Text="" />
		</div>
		</div>
		<div class="DivRow">
		<div  class="DivLabel">
			<asp:Label ID="lblPhoneother" CssClass="TextLabel" runat="server" Text="Điện thoại khác:" />
		</div>
		<div  class="DivTextBox" >
			<asp:TextBox ID="txtPhoneother" CssClass="TextBox" runat="server" Text="" />
		</div>
		</div>
		<div class="DivRow">
		<div  class="DivLabel">
			<asp:Label ID="lblHoten" CssClass="TextLabel" runat="server" Text="Họ tên:" />
		</div>
		<div  class="DivTextBox" >
			<asp:TextBox ID="txtHoten" CssClass="TextBox" runat="server" Text="" />
		</div>
		</div>
        <div class="DivRow">
		<div  class="DivLabel">
			<asp:Label ID="lblYahooid" CssClass="TextLabel" runat="server" Text="Yahoo:" />
		</div>
		<div  class="DivTextBox" >
			<asp:TextBox ID="txtYahooid" CssClass="TextBox" runat="server" Text="" />
		</div>
		</div>
		<div class="DivRow">
		<div  class="DivLabel">
			<asp:Label ID="lblSkypeid" CssClass="TextLabel" runat="server" Text="Skype:" />
		</div>
		<div  class="DivTextBox" >
			<asp:TextBox ID="txtSkypeid" CssClass="TextBox" runat="server" Text="" />
		</div>
		</div>
		<div class="DivRow">
		<div  class="DivLabel">
			<asp:Label ID="lblWeburl" CssClass="TextLabel" runat="server" Text="Website:" /><asp:RegularExpressionValidator
                ID="RegularExpressionValidator1" ValidationExpression="http(s)?://([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)?" ControlToValidate="txtWeburl" Display="None" runat="server" ErrorMessage="Địa chỉ website không hợp lệ."></asp:RegularExpressionValidator>
		</div>
		<div  class="DivTextBox" >
			<asp:TextBox ID="txtWeburl" CssClass="TextBox" runat="server" Text="" />
		</div>
		</div>
  </div>
            <div class="DivRow">
                <div class="DivLabel">
                    &nbsp;&nbsp;&nbsp;</div>
                <div class="DivTextBox">
                    <asp:Button ID="btnSave" runat="server" OnClientClick="getAllImages();" Text=" Lưu "
                        CssClass="btn" />
                    <asp:Button ID="btnHuy" CausesValidation="false" runat="server" Text=" Hủy " CssClass="btn" />&nbsp;
                </div>
            </div>
        </div>
        <div style="display: none">
            <asp:HiddenField ID="hidID" Value="0" runat="server" />
            <asp:TextBox ID="hidImagePath" Text="" runat="server" />
            <asp:TextBox ID="hidStrImage" Text="" runat="server" />
            <asp:TextBox ID="hidStrCommnet" Text="" runat="server" />
        </div>
    </ContentTemplate>
</asp:UpdatePanel>
